﻿<?php

//No direct access
defined('_JEXEC') or die('Restricted access');

$priceformat = OwnserviceHelper::getParams('price_format', '#,###.##');

?>
<script language="javascript" type="text/javascript">
	<!--
		function submitbutton(pressbutton)
		{
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			
			for(var i=0; i<jQuery('input[name="amount_dollar[]"]').length; i++) {
				if(jQuery('#amountdollarid'+(i+1)).val() == "") {
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_AMOUNT_TRANSFER', true ); ?>" );
					document.getElementById('amountdollarid'+(i+1)).focus();
					return;
				}
				if(jQuery('#reasonid'+(i+1)).val() == "") {
					alert( "<?php echo JText::_( 'OWNSERVICE_SELECT_REASON', true ); ?>" );
					document.getElementById('reasonid'+(i+1)).focus();
					return;	
				}	
			}
			submitform( pressbutton );
		}
	-->
</script>
<div id="ownservices">
	<div id="mainmenuownservice"><?php echo MenuHelper::nav(); ?></div>
		<div id="mainownservice">
			 <form action="<?php echo JRoute::_('index.php'); ?>" method="post" name="adminForm">
				<h3><?php echo JText::_('OWNSERVICE_ACCOUNT_FUNDS_TRANSFER'); ?></h3>
				<hr />
				<table width="100%" cellspacing="5" cellpadding="5">
					<?php 
						for( $i=0,$n=count($this->accounts);$i<$n;$i++ ):
						$account  	= $this->accounts[$i];
					?>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_ACCOUNT_NO').' '.($i+1); ?> <span class="red">*</span></td>
						<td><?php echo JHTML::_('select.genericlist', $this->accountlist, 'account[]', 'class="inputbox"', 'value', 'text', $account->account_no); ?></td>
					</tr>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_AMOUNT'); ?> <span class="red">*</span></td>
						<td>
							<input type="text" name="amount_dollar[]" value="" size="10" style="text-align:center;" id="amountdollarid<?php echo $i+1; ?>" autocomplete="off" /> AUD 
							<input type="button" name="acalculation" id="acalculate" value="<?php echo JText::_('OWNSERVICE_CALCULATE'); ?>" onClick="thairate(document.getElementById('amountdollarid<?php echo $i+1; ?>').value, <?php echo ($i+1); ?>)" />
						</td>
					</tr>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_EXCHANGE_RATE'); ?></td>
						<td><?php echo $this->owndata->rate; ?> <?php echo $this->owndata->code; ?>/1 AUD</td>
					</tr>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_FEE'); ?></td>
						<td>
							<input type="text" name="fee[]" id="fee<?php echo $i+1; ?>" value="0.00" readonly="true" class="inputbox" size="10" /> AUD
						</td>
					</tr>
					<tr>
						<td class="key"> <?php echo JText::_('OWNSERVICE_DESTINATION_FEE'); ?></td>
						<td>
							<input type="text" name="bankfee[]" id="bankfee<?php echo $i+1; ?>" value="0.00" class="inputbox" size="10" readonly="true" />  
							<span class="code"><?php echo $this->owndata->code; ?></span>
						</td>
					</tr>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_TOTAL_EXCHANGE'); ?></td>
						<td>
							<input type="text" name="amount_thai[]" value="" size="10" style="text-align:center;" id="amountthaiid<?php echo $i+1; ?>" autocomplete="off" /> <?php echo $this->owndata->code; ?> <input type="button" name="acalculation" id="acalculate" value="<?php echo JText::_('OWNSERVICE_CALCULATE'); ?>" onClick="dollarrate(document.getElementById('amountthaiid<?php echo $i+1; ?>').value, <?php echo ($i+1); ?>)" /></td>
					</tr>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_REASON'); ?> <span class="red">*</span></td>
						<td><?php echo JHTML::_('select.genericlist', $this->reasonlist, 'reason[]', 'class="inputbox" onChange="selectreason(this.value,'.($i+1).');"', 'value', 'text', 'GIFT', 'reasonid'.($i+1)); ?></td>
					</tr>
					<tr>
						<td></td>
						<td><div id="reason<?php echo $i+1; ?>"></div></td>
					</tr>
					<tr>
						<td class="key"><?php echo JText::_('OWNSERVICE_COMMENT'); ?></td>
						<td><textarea name="comment[]" id="comment<?php echo $i+1; ?>" cols="30" rows="3"></textarea></td>
					</tr>
					<tr>
						<td colspan="2"><hr /></td>
					</tr>
					<?php 
						endfor;
					?>
				</table>
				<div style="text-align:center; margin-top:5px;">
				<input type="button" name="next" value="<?php echo JText::_('OWNSERVICE_REQUEST'); ?>" onClick="javascript:submitbutton('confirmdetail');" />
				<input type="button" name="cancel" value="<?php echo JText::_('OWNSERVICE_BUTTONCANCEL'); ?>" onClick="javascript: submitbutton('cancel');" />
				</div>
				<input type="hidden" name="option" value="com_ownservice" />
				<input type="hidden" name="controller" value="ownservice" />
				<input type="hidden" name="task" value="" />
				<?php echo JHTML::_( 'form.token' ); ?>
			 </form>
		</div>
</div>